function Set_Code() {
	var edition="免费版本<font>（ 升级企业尊享版？）</font>";
	if(User.Edition==1){
		edition="企业尊享版";
	}
	var buffer = new StringBuffer();
	buffer.append('<div id="content" class="content" style="margin-top:0px; margin-bottom:0px; padding-top:15px; background-color:#f3f3f3; height:'+(sheight-45)+'px;">');
	buffer.append('<ul class="find">');
	buffer.append('<li id="updatepwd"><div class="quan border-top-bottom"><div class="name" style="padding-left:4%;">修改密码</div><div class="arrow"><img src="img/arrow.png"/></div></div></li>');
	buffer.append('<li style="height:1px; margin-top:20px;"><div class="quan  border-bottom" style="width:100%; float:left; height:1px"></div></li>');
	if(User.ShowUpGrade=="true" && User.UserName!="13523595924")
	{
		buffer.append('<li id="upgrade"><div class="quan border-bottom" style="width:96%;float:right"><div class="name" style="padding-left:0px;width:85%;">'+edition+'</div><div class="arrow"><img src="img/arrow.png"/></div></div></li>');
		buffer.append('<li id="updateclient"><div class="quan border-bottom" style="width:96%;float:right"><div class="name" style="padding-left:0px;">检查升级</div><div class="arrow"><img src="img/arrow.png"/></div></div></li>');
	}
	buffer.append('<li id="aboutus"><div class="quan border-bottom"><div class="name" style="padding-left:4%;">关于企业袋鼠</div><div class="arrow"><img src="img/arrow.png"/></div></div></li>');
	buffer.append('<li id="exist" style="margin-top:20px;"><div class="quan border-top-bottom"><div class="name" style="width:100%; text-align:center;">退出登录</div></div></li>');
	buffer.append('</ul>');
	buffer.append('</div>');
	return buffer.toString();
};

function Init_Set(){
	get("updatepwd").addEventListener("tap",function(){
	 	OpenWindow2(3,"修改密码","保存",function(){
	 		UpdatePwd();
		});
		$("#contentlist3").html(UpdatePwd_Code());
	});
	if(User.ShowUpGrade=="true" && User.UserName!="13523595924")
	{
	get("upgrade").addEventListener("tap",function(){
	 	OpenWindow2(3,"版本升级","",function(){
		});
		$("#contentlist3").html(UpGrade_Code());
	});
	get("updateclient").addEventListener("tap",function(){
		var wt = plus.nativeUI.showWaiting("正在检查升级...");
		CloseWaiting(5000);
		plus.runtime.getProperty(plus.runtime.appid, function(inf) {
            var data = {};
			data.act = "Get_Version";
			data.sign=GetSign(data.act);
			mui.getJSON(index_domain, data, function(json) {
				wt.close();
				if(json.state)
				{
					if(plus.device.vendor=="Apple")
    				{
    					if(json.data.IOSVersion==inf.version)
						{
							plus.nativeUI.alert("当前已经是最新版本");
						}else
						{
							
							plus.nativeUI.confirm("有可升级的版本，是否前往升级？", function(event){
								if(event.index==1)
								{
									DownWgt("qiyedaishu.wgt");
									//window.location.href=json.data.IOSPath;
								}
							},"提示", ["取消","确认"]);
						}
    				}else
    				{
    					if(json.data.AndroidVersion==inf.version)
						{
							plus.nativeUI.alert("当前已经是最新版本");
						}else
						{
							plus.nativeUI.confirm("有可升级的版本，是否前往升级？", function(event){
								if(event.index==1)
								{
									DownWgt("qiyedaishu.apk");
									//OpenWindow(4,"应用升级","",function(){
									//});
									//$("#contentlist4").html("<iframe src='"+json.data.AndroidPath+"' width='100%' height='100%' frameborder='0'></iframe>");
								}
							},"提示", ["取消","确认"]);
						}
    				}
				}else
				{
					plus.nativeUI.toast("检查失败，请重新尝试");
				}
			});
        });
        
	});
	}
	get("aboutus").addEventListener("tap",function(){
	 	OpenWindow2(3,"关于企业袋鼠","",function(){
		});
		$("#contentlist3").html(AboutUs_Code());
		Init_AboutUs();
		plus.runtime.getProperty(plus.runtime.appid, function(inf) {
			$("#version").html(inf.version);
		});
	});
	
	get("exist").addEventListener("tap",function(){
		plus.nativeUI.confirm("确定要退出登录吗？", function(event){
						if(event.index==1)
						{
							addcrm.find(".mui-switch").removeClass("mui-active");
							addoa.find(".mui-switch").removeClass("mui-active");
							addhr.find(".mui-switch").removeClass("mui-active");
							plus.storage.setItem("crm_userid","");
	      					Init_Login();
	      					mapcount=0;
						}
						},"提示", ["取消","确认"]);
	});
};


function UpdatePwd_Code()
{
	var buffer = new StringBuffer();
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">旧密码</div><div class="require">*</div></div><div class="ctext"><input id="txt_oldpwd" type="text" placeholder="填写旧密码" value=""/></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">新密码</div><div class="require">*</div></div><div class="ctext"><input id="txt_newpwd" type="text" placeholder="填写新密码" value="" /></div></div>');
	return buffer.toString();
};

function UpdatePwd(){
	var oldpwd = $("#txt_oldpwd");
    var newpwd = $("#txt_newpwd");
    if (oldpwd.val().Trim()=="") {
        plus.nativeUI.toast("请输入旧密码");
        oldpwd.focus();
        return;
    }
    if (oldpwd.val().length<6 || oldpwd.val().length>18) {
        plus.nativeUI.toast("旧密码长度必须在6-18位之间");
        oldpwd.focus();
        return;
    }
    if (newpwd.val().Trim()=="") {
        plus.nativeUI.toast("请输入新密码");
        newpwd.focus();
        return;
    }
    if (newpwd.val().length < 6 || newpwd.val().length > 18) {
        plus.nativeUI.toast("新密码长度必须在6-18位之间");
        newpwd.focus();
        return;
    }


    
	var data = {};
		data.act = "Save_Pwd";
	    data.oldpwd = oldpwd.val();
	    data.newpwd = newpwd.val();
	    data.userid=userid;
		data.comid=comid;
		data.source=source;
		data.sign=GetSign(data.act);
		mui.getJSON(oa_domain, data, function(json) {
			plus.nativeUI.toast(json.msg);
			if(json.state)
			{
				CloseWindow();
			}
		});
};

function AboutUs_Code(){
	var buffer = new StringBuffer();
	buffer.append('<div class="aboutus"><div class="logo"><img src="img/logo.png"></div><div class="version">当前版本：<font id="version"></font></div><div class="phone">服务热线：<a href="tel:18530098293">18530098293</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class="website">官方网站：<a id="websites" href="javascript:void(0)">www.qiyedaishu.com&nbsp;</a></div><div class="copyright">铭恩科技 &nbsp; 版权所有</div><div class="inc">© 2014-2016 qiyedaishu Inc. All Rights Reserved.</div></div>');
	return buffer.toString();
};

function Init_AboutUs(){
	get("websites").addEventListener("tap",function(){
		OpenWindow(4,"官方网站","",function(){
		});
		$("#contentlist4").html("<iframe src='http://www.qiyedaishu.com' width='100%' height='100%' frameborder='0'></iframe>");
	});
};

function UpGrade_Code(){
	var buffer = new StringBuffer();
	buffer.append('<div class="upgrade"><div class="titles">免费版本</div><div class="contexts">1.企业袋鼠对所有喜欢我们软件的用户终身免费<br>2.企业袋鼠承诺免费版本和企业尊享版享有一模一样的功能<br>3.免费版本和企业尊享版的唯一区别就是：免费版本不提供云端数据备份的功能，如果出现意外（比如地震，台风，洪水等自然灾害），数据将不可恢复；企业尊享版所有数据都在云端实时备份</div><div class="titles">企业尊享版</div><div class="contexts">1.免费上门培训<br>2.提供一对一业务经理7*24小时免费售后服务<br>3.企业数据如果出现不可抗拒的毁灭，100%承诺2小时内恢复，数据如果出现员工错删，误删或者其他恶意删除，联系业务经理2小时内恢复<br>4.其他更多优质服务，可以直接点击后边电话联系高经理详细咨询：<a href="tel:18530098293">18530098293</a></div></div>');
	return buffer.toString();
};
